package com.broada.apm.topo;

import com.broada.apm.model.Resource;


public class TResource <T extends TService>{
		private String uri;
		private int protocol;
		private String protocolName;
		private int port;
		private long ipNum;
		private String id;
		
		protected Resource resource;
		
		public TResource(Resource resource, String id, long ip, int port, int protocol, String protocolName, String uri) {
			this.id = id;
			this.uri = uri;
			this.protocol = protocol;
			this.protocolName = protocolName;
			this.ipNum = ip;
			this.port = port;
			this.resource = resource;
		}
		public String getUri() {
			return uri;
		}
		public int getProtocol() {
			return protocol;
		}
		public String getProtocolName() {
			return protocolName;
		}
		public Resource getResource() {
			return resource;
		}
		
		@Override
		public String toString() {
			return "TResource [uri=" + uri + ", protocol=" + protocol  + ", protocolName="
					+ protocolName + ", port=" + port + ", ipNum=" + ipNum + ", id=" + id + ", resource=" + resource + "]";
		}
		
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + protocol;
			result = prime * result + ((uri == null) ? 0 : uri.hashCode());
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			TResource<?> other = (TResource<?>) obj;
			if (protocol != other.protocol)
				return false;
			if (uri == null) {
				if (other.uri != null)
					return false;
			} else if (!uri.equals(other.uri))
				return false;
			return true;
		}
		public String getId() {
			return id;
		}
		
	}